package org.example.demo.atomic;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.atomic.AtomicReference;

@Slf4j
public class AtomicExample4 {


    public static AtomicReference<Integer> reference = new AtomicReference<>(0);

    public static void main(String[] args) {
        reference.compareAndSet(0,2);  //2
        reference.compareAndSet(1,2);  //no
        reference.compareAndSet(2,4);  //4
        reference.compareAndSet(3,5);  //no
        reference.compareAndSet(5,7);  //no
        reference.compareAndSet(4,10); //10
        log.info("reference: {}",reference.get());
    }
}
